<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="inputValue" @keyup.enter="add">
        <div v-for="(item,index) in list" :key="index">
                    <span>{{index+1}}</span>
                    <label>{{item}}</label>
                    <button @click="remove(index)">删除</button>
        </div>
        <div>
             <span v-if="list.length!=0">总计：{{list.length}}条</span>    
             <button v-if="list.length!=0" @click="empty">清空</button>   
        </div>

    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        var app=new Vue({
            el:"#app",
            data:{
                list:["ha","he","aa"],
                inputValue:""
            },
            methods:{
                add:function(){
                    this.list.push(this.inputValue)
                },
                remove:function(index){
                    this.list.splice(index,1)
                },
                empty:function(){
                    this.list=[]
                    this.inputValue=""
                }
            }
        })
    </script>
</body>
</html>